<template>
    <div>

        <group title="cell demo">
            <!--使用 router-link 跳转 -->
            <!--<router-link to="hello">-->
            <!--<cell title="Go to hello with router link" value="click me" is-link></cell>-->
            <!--</router-link>-->
            <!--<router-link to="index">-->
            <!--<cell title="Go to hello with router link" value="click me" is-link></cell>-->
            <!--</router-link>-->

            <!--&lt;!&ndash;使用 router.push 跳转 &ndash;&gt;-->
            <!--<cell title="Go to hello with router push" @click.native="goNext" is-link></cell>-->
            <!--<div>{{ isTitle }}</div>-->
            <!--<button style="height: 30px;width: 100px;background-color: red"  @click="changeTitle" ></button>-->

            <router-link to="foodDetail/111">
                <cell title="餐品详情" value="click me" is-link></cell>
            </router-link>
            <router-link to="diningMode">
                <cell title="就餐方式" value="click me" is-link></cell>
            </router-link>
            <router-link to="historyOrder">
                <cell title="历史订单" value="click me" is-link></cell>
            </router-link>
            <router-link to="switchCity">
                <cell title="切换城市" value="click me" is-link></cell>
            </router-link>
            <router-link to="xstore">
                <cell title="门店首页" value="click me" is-link></cell>
            </router-link>
        </group>


    </div>
</template>

<script>
    import {mapState, mapActions} from 'vuex'
    import {Group, Cell, Confirm, Alert} from 'vux'

    import URLParser from '../tools/URLParser'
    import {MockService} from '../services'

    export default {
        components: {Confirm, Group, Cell, Alert},
        data () {

            return {
                msg: 'Hello World!',
                shownConfirm: false,
                username: null,
            }
        },
        created(){

//            如何使用 tools
            var myParser = new URLParser('http://www.a.com/b/c/?q=123#top')

            console.log('======URLParser=== q is :', myParser.getQuery('q'))

//            如何发送一个 ajax 请求：
            MockService().get().then(res => {
                console.log('========== ajax', res)
            })
        },
        computed: {
            ...mapState({
                count: state => state.vux.count,
                isTitle: state => state.default.isTitle
            })
        },
        methods: {
            ...mapActions([
                'updateCountStatus',
                'updateIsTitle'
            ]),
            goNext(){
                this.$router.push({name: 'hello'})
            },
            changeTitle(){
                this.updateIsTitle(!this.isTitle)
            }
        }
    }
</script>
<style lang="less" rel="stylesheet/less" scoped>
    .vux-demo {
        text-align: center;
    }

    .logo {
        width: 100px;
        height: 100px
    }
</style>
